Skip to content

chore: roll up PRs #1 + #2 + strip deployment refs into one reviewable branch#4

Closed
m0nk111-post wants to merge 1 commit into
mainfrom
chore/clean-fork-off-upstream
Closed

chore: roll up PRs #1 + #2 + strip deployment refs into one reviewable branch#4
m0nk111-post wants to merge 1 commit into
mainfrom
chore/clean-fork-off-upstream

Conversation

@m0nk111-post

@m0nk111-post m0nk111-post commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

What

One commit. Replaces PRs #1, #2 and the (closed) #3 with a single reviewable change. Everything that was discussed in those PRs is now rolled into the body of this one commit.

Branch setup

What the one commit does

1. Steer the skill and the prompt at the GitHub Pull Request Reviews API

Previously the github-pr-review skill and the agent prompt both documented the correct API (POST /repos/{owner}/{repo}/pulls/{n}/reviews with a comments[] array), but on real PRs the agent kept falling back to gh pr comment (issue-level blob) and losing inline threads and suggestion blocks.

The fix:

  • plugins/pr-review/scripts/prompt.py: a "How to Post the Review (CRITICAL — read first)" block right under the /github-pr-review trigger. It includes a worked bash + JSON example, mandates the Reviews API, and explicitly forbids gh pr comment / POST /issues/{n}/comments. The {owner}/{repo}/{n} tokens are escaped ({{...}}) so they survive str.format().
  • skills/github-pr-review/SKILL.md: rewritten to match the github-code-quality[bot] format — ## <Priority> <Category> heading, one-line statement, --- separator, "Best fix in this file" anchor, scope confirmation, optional ```suggestion ``` block. Pre-Review Checks, "One PR Review, One API Call, Many Inline Comments", Good vs Bad Inline Comments, edge cases, and a Summary Checklist.
  • skills/index.js: regenerated from the updated SKILL.md.

2. Add the agent-canvas-automation cron runner (v2.7 + v2.8 shipped together)

A standalone OpenHands Automations script that, on a cron tick:

  1. Polls the configured repo for open PRs carrying the trigger label.
  2. Forks a fresh OpenHands conversation per (PR, label_event_id) and feeds it the review prompt.
  3. Waits for the conversation to reach a terminal state (finished / error / stuck / idle).
  4. Parses a ###REVIEW_JSON### contract out of the final response.
  5. Posts the result as a single Pull Request Review with one inline thread per finding.

Cross-cutting features in both v2.7 and v2.8:

  • Path validation: comments whose path is not in the PR diff are dropped with a log line (GitHub returns 422 otherwise).
  • Author-equals-reviewer coalesce: REQUEST_CHANGES is auto-downgraded to COMMENT when the bot user is the PR author (GitHub returns 422 otherwise).
  • Re-review guard: already-closed (PR, label_event_id) pairs are skipped on the next cron tick.
  • MCP-direct detection: if the agent posted the review via the GitHub MCP instead of the JSON contract, the script queries GitHub for existing reviews by the bot user (resolved at runtime via GET /user with the same token that posts the review) and closes the state without double-posting.
  • ###REVIEW_JSON### parser: brace-counting parser with a last-marker-wins rule, handles both fenced ```json` and raw inline JSON.

What v2.8 adds on top of v2.7: the duplicate-review guard runs in both the "no JSON" and "have JSON" paths. Without it, a run where the agent posts via the GitHub MCP AND the script posts from the parsed JSON produces two reviews with identical content. With it, only the first one sticks.

3. Make the runner deployment-neutral

This is the bit that was discussed in PR #3 and ended up simpler than the original proposal.

  • REPO is no longer hardcoded. It's an empty string with a TODO comment pointing at the /pr-reviewer:setup skill. Until REPO is filled in, _verify_token_and_repo will fail with a 404 against an empty path — fail-fast by design, and easier to spot than posting to the wrong repo. The setup skill substitutes this line as one of its deployment-constants step.
  • The bot-user check is resolved at runtime, not configured. _get_bot_login(token) calls GET /user with the same GITHUB_TOKEN / GITHUB_PERSONAL_ACCESS_TOKEN that posts the review and caches the result for the rest of the cron tick. Works for both kinds of token with no extra config.
  • The README + SKILL.md references are deployment-neutral — no more "matches PR #379 on the test repo" wording, no more direct links to specific PRs in the demo table.

What was decided but NOT done

  • An env-var override for REPO was proposed in PR chore: strip deployment-specific refs from pr-review plugin #3 and rejected. REPO stays as a code-level constant because the /pr-reviewer:setup skill already substitutes it at build time — turning it into an env var would mean the setup skill has to substitute the substitution point too, with no upside.
  • The v2.8 JSON parser bug (newline-in-string breaks the brace counter) is out of scope for this PR. Will be addressed in a v2.9/main.py follow-up after this lands.

Verification

  • python3 -c "import ast; ast.parse(open('.../v2.7/main.py').read())" -> OK
  • python3 -c "import ast; ast.parse(open('.../v2.8/main.py').read())" -> OK
  • grep -rnE "m0nklabs|cryptotrader|m0nk111-post|pull/379|PR 379|PR #379" on the whole tree -> zero hits. (Confirmed both against the working tree and against git diff upstream/main..HEAD.)
  • git log --all -S m0nklabs -S m0nk111-post -S cryptotrader --diff-filter=A -> zero hits in any commit reachable from this branch (other than the upstream base).
  • node scripts/build-skills-catalog.mjs regenerated skills/index.js cleanly.
  • git log upstream/main..HEAD -> 1 commit, linear, no merges.

Reviewing this PR

There is exactly one commit. The commit message itself has a "What this does" section that mirrors the three headings above. Click into the diff and you can read the three layers in this order:

  1. Start with skills/github-pr-review/SKILL.md and plugins/pr-review/scripts/prompt.py (the API switch).
  2. Then read plugins/pr-review/agent-canvas-automation/v2.7/main.py and v2.8/main.py (the cron runner — this is the bulk of the diff).
  3. Skim the README files in plugins/pr-review/agent-canvas-automation/ for the deploy-neutral doc updates.

…te guard + deployment-neutral config

Consolidates the work that was previously proposed as PRs #1, #2 and #3
into a single reviewable change.

## What this does

1. Steers the github-pr-review skill and the agent prompt at the GitHub
   Pull Request Reviews API (POST /repos/{owner}/{repo}/pulls/{n}/reviews
   with a comments[] array) instead of the issue-comments API. Inline
   threads, suggestion blocks, and one-click-apply now actually work.

2. Adds the agent-canvas-automation cron runner that watches one repo
   for a trigger label, forks a fresh OpenHands conversation per
   (PR, label_event_id), waits for the conversation to finish, parses
   a ###REVIEW_JSON### contract out of the final response, and posts
   the result as a single Pull Request Review. v2.7 and v2.8 are
   shipped together; the difference between them is the duplicate-review
   guard (see below).

3. Makes the duplicate-review guard robust: before posting a parsed
   payload, the script queries GitHub for an existing review by the
   bot user at the same commit_id. If one is found, the script closes
   the state without re-posting — that fixes the race where the agent
   posts via the GitHub MCP and the script also posts from the parsed
   JSON, producing two reviews with identical content.

4. Removes every hardcoded reference to the original test deployment
   from this repo. The cron runner is generic now: REPO is an empty
   string with a TODO pointing at /pr-reviewer:setup, the bot-user
   check is resolved at runtime via GET /user with the same token that
   posts the review, and the SKILL.md / README references are
   deployment-neutral.

## Files

M  plugins/pr-review/scripts/prompt.py
M  skills/github-pr-review/SKILL.md
M  skills/index.js
A  plugins/pr-review/agent-canvas-automation/README.md
A  plugins/pr-review/agent-canvas-automation/v2/README.md
A  plugins/pr-review/agent-canvas-automation/v2.7/main.py
A  plugins/pr-review/agent-canvas-automation/v2.8/main.py

## Behavioural impact

- New env vars: none.
- One extra GET /user per cron tick (cached thereafter). That's well
  within the 5000/hr PAT budget.
- Until REPO is filled in by /pr-reviewer:setup, _verify_token_and_repo
  will fail with a 404 against an empty path — fail-fast by design.

## Verification

- python3 -c 'import ast; ast.parse(...)' on v2.7 + v2.8 main.py -> OK
- grep -rnE 'm0nklabs|cryptotrader|m0nk111-post|pull/379|PR 379|PR #379'
  on the whole tree -> zero hits (the previous test-deployment literal
  that used to live in REPO = ... is gone; REPO is now empty).
- node scripts/build-skills-catalog.mjs regenerated skills/index.js
  cleanly.

Co-authored-by: openhands <openhands@all-hands.dev>
@m0nk111-post m0nk111-post force-pushed the chore/clean-fork-off-upstream branch from 23ba23e to 1e1b54d Compare June 17, 2026 14:42
@m0nk111-post m0nk111-post deleted the chore/clean-fork-off-upstream branch June 17, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants